package com.controller;

import com.pojo.Hua.HuaBeginOrder;
import com.service.iter.IProductionOrderService;
import com.util.Res;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Objects;

/**
 * 生产指令控制器
 *
 * @author admin
 * @date 2023/06/20
 */
@RestController
@RequestMapping("production/")
public class ProductionOrderController {

    /**
     * 生产订单服务
     */
    @Autowired
    private IProductionOrderService iProductionOrderService;

    /**
     * 获得生产指令
     *
     * @return {@link Res}
     */
    @GetMapping("getProductionOrder")
    public Res getProductionOrder() {
        Res res = new Res();
        List<HuaBeginOrder> productionOrders = iProductionOrderService.queryAll();
        if (Objects.isNull(productionOrders)) {
            res.setCode(404);
            res.setMsg("无销售产品");
        } else {
            res.setCode(200);
            res.setData(productionOrders);

        }
        return res;
    }
}
